  import http from "@/http";
import { 
  MaterialPricing, 
  MaterialPricingListParam, 
  MaterialPricingCreateParam,
  MaterialPricingUpdateParam,
  MaterialPricingUpdateStatusParam,
  MaterialPricingBatchUpdateStatusParam,
  MaterialPricingBatchCopyParam,
  ExportRequest 
} from "./type";

/**
 * 分页查询物料核价列表
 */
export const getListApi = (data: MaterialPricingListParam) => {
  return http.get("/materialPricing/list", data);
};

/**
 * 创建物料核价
 */
export const addApi = (data: MaterialPricingCreateParam) => {
  return http.post("/materialPricing/create", data);
};

/**
 * 更新物料核价
 */
export const editApi = (data: MaterialPricingUpdateParam) => {
  return http.put("/materialPricing/update", data);
};

/**
 * 删除物料核价
 */
export const deleteApi = (id: number) => {
  return http.delete(`/materialPricing/delete/${id}`);
};

/**
 * 根据ID查询物料核价
 */
export const getByIdApi = (id: number) => {
  return http.get(`/materialPricing/${id}`);
};

/**
 * 更新物料核价状态
 */
export const updateStatusApi = (data: MaterialPricingUpdateStatusParam) => {
  return http.put("/materialPricing/updateStatus", data);
};

/**
 * 批量删除物料核价
 */
export const batchDeleteApi = (ids: number[]) => {
  return http.post("/materialPricing/batchDelete", { ids });
};

/**
 * 批量更新物料核价状态
 */
export const batchUpdateStatusApi = (data: MaterialPricingBatchUpdateStatusParam) => {
  return http.put("/materialPricing/batchUpdateStatus", data);
};

/**
 * 导出物料核价数据
 */
export const exportApi = (data: MaterialPricingListParam) => {
  return http.get("/materialPricing/export", data, { responseType: 'blob' });
};

/**
 * 导出自定义字段数据
 */
export const exportCustomFieldsApi = (data: ExportRequest) => {
  return http.post("/materialPricing/exportCustomFields", data, { responseType: 'blob' });
};

/**
 * 获取可导出字段列表
 */
export const getExportFieldsApi = () => {
  return http.get("/materialPricing/getExportFields");
};

/**
 * 下载导入模板
 */
export const downloadTemplateApi = () => {
  return http.get("/materialPricing/downloadTemplate", {}, { responseType: 'blob' });
};

/**
 * 导入物料核价数据
 */
export const importApi = (data: FormData) => {
  return http.post("/materialPricing/import", data, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

/**
 * 批量复制物料核价
 */
export const batchCopyApi = (data: MaterialPricingBatchCopyParam) => {
  return http.post('/materialPricing/batchCopy', data);
}; 